package cn.java71.servlet;

import cn.java71.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(name = "studentLoginServlet",value = "/studentLoginServlet")
public class studentLoginServlet extends HttpServlet {
    StudentService studentService =new StudentService();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String no=request.getParameter("no");
        String pass=request.getParameter("pass");
        //...
        if(no.equals("10")&&pass.equals("12345")){
            HttpSession session = request.getSession();
            session.setAttribute("STU_LOGIN",no);
            request.getRequestDispatcher("/welcomestudent.jsp").forward(request,response);
        }else{
            response.sendRedirect("studentlogin.jsp");
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
